package com.project.controller.employeeController;

import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.bean.ServeOrderBean;
import com.project.bean.StoreBean;
import com.project.mapper.employeeMapper.IEmployeeMapper;
import com.project.service.employeeService.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private IEmployeeMapper mapper;

    @RequestMapping("/add")
    public String add(EmployeeBean employeeBean,int storeId){
        StoreBean store = new StoreBean();
        employeeBean.setStore(store);
        employeeBean.getStore().setId(storeId);
        employeeService.add(employeeBean);
        return "ok";
    }

    @RequestMapping("/del")
    public String del(int id){
        employeeService.del(id);
        return "ok";
    }

    @RequestMapping("/update")
    public String update(int id, String tel, String skill){
        employeeService.update(id, tel, skill);
        return "ok";
    }

    @RequestMapping("/findById")
    public EmployeeBean findById(int id){
        return employeeService.findById(id);
    }

    @RequestMapping("/findBySkill")
    public PageInfo<EmployeeBean> findBySkill(Integer pageNO,String skill, Integer storeId){
        return employeeService.findBySkill(pageNO, skill, storeId);
    }

    @RequestMapping("/findAll")
    public PageInfo<EmployeeBean> findAll(int pageNO, int storeId){

        return employeeService.findAll(pageNO, storeId);
    }
    @RequestMapping("/findListAll")
    public List<EmployeeBean> findListAll(int storeId){

        return mapper.findAll(storeId);
    }

}
